// pages/zhuren/zhuren.js
import * as echarts from '../../ec-canvas/echarts' // 这个是自己实际的目录

var chart1;


function initChart(canvas, width, height, dpr) { // 这部分是固定的不需要 是通用的
    const chart = echarts.init(canvas, null, {
        width: width,
        height: height
    });
    canvas.setChart(chart);
    // 这是 唯一需要更改的，可根据实际情况api更改图标
    // 我这边测试的是一个 普通的折线图,案例网址:
    var option = {
        xAxis: {
            type: 'category',
            data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        },
        yAxis: {
            type: 'value'
        },
        series: [{
            data: [820, 932, 901, 934, 1290, 1330, 1320],
            type: 'line'
        }]
    };

    chart.setOption(option);
    return chart;
}

function getOption1() {
    return {
        tooltip: {
            trigger: 'axis',
            axisPointer: { // 坐标轴指示器，坐标轴触发有效
                type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
            },
            confine: true
        },
        legend: {
            data: ['C2109A班', 'C2109B班', 'C2109C班']
        },
        grid: {
            left: 20,
            right: 20,
            bottom: 15,
            top: 40,
            containLabel: true
        },
        xAxis: [{
            type: 'category',
            axisTick: {
                show: false
            },
            data: ['C2109'],
            axisLine: {
                lineStyle: {
                    color: '#999'
                }
            },
            axisLabel: {
                color: '#666'
            }
        }],
        yAxis:[{
            type: 'value',
            axisLine: {
                lineStyle: {
                    color: '#999'
                }
            },
            axisLabel: {
                color: '#666'
            }
        }], 
        series: [{
                name: 'C2109A班',
                type: 'bar',
                data: [80],
            },
            {
                name: 'C2109B班',
                type: 'bar',
                data: [60],
            },
            {
                name: 'C2109C班',
                type: 'bar',
                data: [100],
            }
        ]

    }
}
function getOption2() {
    return {
        tooltip: {
            trigger: 'axis',
            axisPointer: { // 坐标轴指示器，坐标轴触发有效
                type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
            },
            confine: true
        },
        legend: {
            data: ['C2109A班', 'C2109B班', 'C2109C班']
        },
        grid: {
            left: 20,
            right: 20,
            bottom: 15,
            top: 40,
            containLabel: true
        },
        yAxis: [{
            type: 'category',
            axisTick: {
                show: false
            },
            data: ['C2109'],
            axisLine: {
                lineStyle: {
                    color: '#999'
                }
            },
            axisLabel: {
                color: '#666'
            }
        }],
        xAxis:[{
            type: 'value',
            axisLine: {
                lineStyle: {
                    color: '#999'
                }
            },
            axisLabel: {
                color: '#666'
            }
        }], 
        series: [{
                name: 'C2109A班',
                type: 'bar',
                data: [12000],
            },
            {
                name: 'C2109B班',
                type: 'bar',
                data: [12000],
            },
            {
                name: 'C2109C班',
                type: 'bar',
                data: [13000],
            }
        ]

    }
}
function getOption3() {
    return {
        tooltip: {
            trigger: 'axis',
            axisPointer: { // 坐标轴指示器，坐标轴触发有效
                type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
            },
            confine: true
        },
        legend: {
            data: ['C2109A班', 'C2109B班', 'C2109C班']
        },
        grid: {
            left: 20,
            right: 20,
            bottom: 15,
            top: 40,
            containLabel: true
        },
        xAxis: [{
            type: 'category',
            axisTick: {
                show: false
            },
            data: ['C2109'],
            axisLine: {
                lineStyle: {
                    color: '#999'
                }
            },
            axisLabel: {
                color: '#666'
            }
        }],
        yAxis:[{
            type: 'value',
            axisLine: {
                lineStyle: {
                    color: '#999'
                }
            },
            axisLabel: {
                color: '#666'
            }
        }], 
        series: [{
                name: 'C2109A班',
                type: 'bar',
                data: [20],
            },
            {
                name: 'C2109B班',
                type: 'bar',
                data: [15],
            },
            {
                name: 'C2109C班',
                type: 'bar',
                data: [30],
            }
        ]

    }
}
Page({

    /**
     * 页面的初始数据
     */
    data: {
        active: 0,
        ec1: {
            onInit: function (canvas, width, height) {
                chart1 = echarts.init(canvas, null, {
                    width: width,
                    height: height
                })
                canvas.setChart(chart1);
                chart1.setOption(getOption1());
                // that.loadData();
                return chart1;
            }
        },
        ec2: {
            onInit: function (canvas, width, height) {
                chart1 = echarts.init(canvas, null, {
                    width: width,
                    height: height
                })
                canvas.setChart(chart1);
                chart1.setOption(getOption2());
                // that.loadData();
                return chart1;
            }
        },
        ec3: {
            onInit: function (canvas, width, height) {
                chart1 = echarts.init(canvas, null, {
                    width: width,
                    height: height
                })
                canvas.setChart(chart1);
                chart1.setOption(getOption3());
                // that.loadData();
                return chart1;
            }
        },
        list: {
            user: '彭彬',
            zhiwu: '项目经理',
            fangxiang: '短视频运营'
        },
        option2: [{
                text: '当期',
                value: 'a'
            },
            {
                text: '2108',
                value: 'b'
            },
            {
                text: '2107',
                value: 'c'
            },
        ],
        value2: 'a',
    },
    onChange(e) {
        // console.log("e:", e);
        this.setData({
            active: e.detail.index
        })
    },
    onClickLeft() {
        wx.showToast({
            title: '点击返回',
            icon: 'none'
        });
    },
    onClickRight() {
        wx.showToast({
            title: '点击按钮',
            icon: 'none'
        });
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {},

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})